package com.abel.factory;

import com.abel.tactics.Handler;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 工厂设计模式
 *
 * @author heyangyang
 * @since 2024-05-15
 */
public class Factory {

    private static Map<String, Handler> strategyMap = new HashMap<>();

    public static Handler getInvokeStrategy(String str) {
        return strategyMap.get(str);
    }

    public static void registerStrategy(String str, Handler handler) {
        if (StringUtils.isBlank(str) || Objects.isNull(handler)) {
            return;
        }
        strategyMap.put(str, handler);
    }

}
